import { Component, OnInit } from '@angular/core';
import {Page} from '../../../public/util/page';
import {SettingUrl} from '../../../public/setting/setting_url';
import {Enums, JlbAccountState} from '../../../public/setting/enums';
import {UserService} from '../user.service';

@Component({
  selector: 'app-user-active',
  templateUrl: './user-active.component.html',
  styleUrls: ['./user-active.component.css']
})
export class UserActiveComponent implements OnInit {
  public searchParams: any = {};//搜索参数
  public userActiveList: Page = new Page(); //供应商
  public _loading: boolean = false;
  public routerLinks = SettingUrl.ROUTERLINK;//路由
  public states = Enums.userJlbState;       // 状态
  public jlbAccountState = JlbAccountState;

  constructor(private userService: UserService) {
  }

  ngOnInit() {
    this.queryUserActiveList()
  }

  /**
   * 查询userJlb列表
   * @param curPage 当前页
   */
  queryUserActiveList(curPage?: number) {
    this._loading = true;
    if (curPage) this.userActiveList.curPage = curPage;//当有页码时，查询该页数据
    this.userActiveList.params = {
      account: this.searchParams.account, //account
      curPage: this.userActiveList.curPage, //目标页码
      pageSize: this.userActiveList.pageSize, //每页条数
    };
    this.userService.getUserActiveList(this.userActiveList.params).then((res: Page) => {
      this._loading = false;
      this.userActiveList = res;
    }).catch(err => {
      this._loading = false;
    })
  }

  /**
   * 重置搜索
   */
  resetSearch() {
    this.searchParams = {};
    this.queryUserActiveList(1)
  }
}
